require 'fastlane/action'
require_relative '../helper/open_folder_helper'

module Fastlane
  module Actions
    class OpenFolderAction < Action
      def self.run(params)
        path = params[:path]
        system("open #{path}")
        Fastlane::Helper::OpenFolderHelper.show_message
      end

      def self.description
        "open a path with finder"
      end

      def self.authors
        ["suqiang"]
      end

      def self.return_value
        # If your method provides a return value, you can describe here what it does
      end

      def self.details
        # Optional:
        "open a path with finder detail"
      end

      def self.available_options
        [
          FastlaneCore::ConfigItem.new(key: :path,
                                  env_name: "OPEN_FOLDER_YOUR_OPTION",
                               description: "path of your open",
                                  optional: false,
                                      type: String)
        ]
      end

      def self.is_supported?(platform)
        # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
        # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
        #
        # [:ios, :mac, :android].include?(platform)
        true
      end
    end
  end
end
